package cn.edu.neusoft.neufooddemo.model;

import cn.edu.neusoft.neufooddemo.common.Constants;
import cn.edu.neusoft.neufooddemo.listener.RetrofitListener;
import cn.edu.neusoft.neufooddemo.service.FoodService;
import retrofit2.Call;

/**
 * Created by Shinelon on 2017/4/10.
 */

public class FoodModel extends RetrofitBaseModel{
    private FoodService foodService;
    public FoodModel()
    {
        this.foodService = retrofit.create(FoodService.class);
    }

    public void getFoodByShop(String shop_id, RetrofitListener listener) {
        Call call = foodService.getFoodByShop(shop_id);
        bindCallback(call,listener,Constants.GETFOODBYSHOP);
    }


    public void getFoodBySearch(String search,RetrofitListener listener) {
        Call call = foodService.getFoodBySearch(search);
        bindCallback(call,listener,Constants.GETFOODBYSEARCH);
    }
 /*   public void getAllCommentsByFood(String food_id,RetrofitListener listener) {
        Call  call = foodService.getAllUserOrder(user_id);
        bindCallback(call,listener,Constants.GETALLUSERORDER);
    }*/
    public void getAllUserOrder(String user_id,RetrofitListener listener) {
        Call  call = foodService.getAllOrdersByUser(user_id);
        bindCallback(call,listener,Constants.GETALLUSERORDER);
    }

    public void getFoodById(String food_id,RetrofitListener listener) {
        Call  call = foodService.getFoodById(food_id);
        bindCallback(call,listener,Constants.GETFOODBYID);
    }
    public void getAllUserComment(String user_id,RetrofitListener listener) {
        Call call = foodService.getAllCommentsByUser(user_id);
        bindCallback(call,listener,Constants.GETALLUSERCOMMENT);
    }
    public void isCollected(String user_id, String shop_food_id, String flag,RetrofitListener listener) {
        Call call = foodService.isCollected(user_id,shop_food_id,flag);
        bindCallback(call,listener,Constants.ISCOLLECTED);
    }
    public void getAllCommentsByFood(String food_id,RetrofitListener listener) {
        Call call = foodService.getAllCommentsByFood(food_id);
        bindCallback(call,listener,Constants.GETALLUSERFOODORDER);
    }
 public void updateComment(String item_id, String content,RetrofitListener listener) {
        Call call = foodService.updateComment(item_id,content);
        bindCallback(call,listener,Constants.UPDATECOMMENT);
    }
    public void deleteComment(String item_id,RetrofitListener listener) {
        Call call = foodService.deleteComment(item_id);
        bindCallback(call,listener,Constants.DELETECOMMENT);
    }

    public void insertComment(String item_id, String content,RetrofitListener listener) {
        Call call = foodService.insertComment(item_id,content);
        bindCallback(call,listener,Constants.INSERTCOMMENT);
    }
    public void addCart(String user_id,String food_id,int num,RetrofitListener listener)
    {
        Call call = foodService.addCart(user_id,food_id,num);
        bindCallback(call,listener,Constants.ADDCART);
    }

    public void getMyCartByUser(String user_id,RetrofitListener listener) {
        Call call = foodService.getMyCartByUser(user_id);
        bindCallback(call,listener,Constants.GETMYCART);
    }

    public void doDeleteItem(String item_id,RetrofitListener listener) {
        Call call = foodService.deleteCartItem(item_id);
        bindCallback(call,listener,Constants.DELETEITEM);
    }

    public void getItemsFromCart(String items,RetrofitListener listener) {
        Call call = foodService.getItemsFromCart(items);
        bindCallback(call,listener,Constants.GETITEMSFROMCART);
    }
}
